// 77. 组合
// AC: https://leetcode.cn/problems/combinations/submissions/621106881/

class Solution {
public:
    vector<vector<int>> ans;
    vector<int> res;
    void dfs(int d,int l,int n,int k){
        if(d==k){
            ans.push_back(res);
            return;
        }
        for(int i=l+1;i<=n;++i){
            res.push_back(i);
            dfs(d+1,i,n,k);
            res.pop_back();
        }
    }
    vector<vector<int>> combine(int n, int k) {
        dfs(0,0,n,k);
        return ans;
    }
};